/*
 * MyGUI.h
 *
 *  Created on: 10.09.2013
 *      Author: radu
 */

#ifndef MYGUI_H_
#define MYGUI_H_

#include "my_gtk.h"
#include "MySQL.h"

class My_GUI
{
public:
	static void get_iter_last( GtkTreeModel *mdl, GtkTreeIter *itr );
	static void add_item (GtkWidget *button, gpointer data);
	static void remove_item (GtkWidget *widget, gpointer data);
	static gboolean separator_row (GtkTreeModel *model,
	               GtkTreeIter  *iter,
	               gpointer      data);
	static void editing_started (GtkCellRenderer *cell,
	                 GtkCellEditable *editable,
	                 const gchar     *path,
	                 gpointer         data);
	static void cell_edited (GtkCellRendererText *cell,
	             const gchar         *path_string,
	             const gchar         *new_text,
	             gpointer             data);
	static void fixed_toggled (GtkCellRendererToggle *cell,
	               gchar                 *path_str,
	               gpointer               data);
	static void add_columns (GtkTreeView  *treeview,
	             GtkTreeModel *items_model,
	             GtkTreeModel *products_model);
	static void add_treeview();
	static void interactive_dialog_clicked (GtkButton *button,
				    gpointer   user_data);
	static void activate_action (GtkAction *action);
	static void activate_radio_action (GtkAction *action, GtkRadioAction *current);
	static gchar * demo_find_file (const char *base, GError    **err);
	static void about_cb (GtkAction *action,
		  GtkWidget *window);
	static void add_menu();
};

static GtkActionEntry entries[] = {
  { "EditMenu", NULL, "_Edit" },               /* name, stock id, label */
  { "PreferencesMenu", NULL, "_Preferences" }, /* name, stock id, label */
  { "ColorMenu", NULL, "_Color"  },            /* name, stock id, label */
  { "ShapeMenu", NULL, "_Shape" },             /* name, stock id, label */
  { "HelpMenu", NULL, "_Help" },               /* name, stock id, label */
  { "New", GTK_STOCK_NEW,                      /* name, stock id */
    "_New", "<control>N",                      /* label, accelerator */
    "Create a new record",                       /* tooltip */
    G_CALLBACK (My_GUI::add_item) },
  { "Open", GTK_STOCK_OPEN,                    /* name, stock id */
    "_Open","<control>O",                      /* label, accelerator */
    "Open a file",                             /* tooltip */
    G_CALLBACK (My_GUI::interactive_dialog_clicked) },
  { "Save", GTK_STOCK_SAVE,                    /* name, stock id */
    "_Save","<control>S",                      /* label, accelerator */
    "Save current recordset",                       /* tooltip */
    G_CALLBACK (My_SQL::save_items) },
  { "Delete", GTK_STOCK_DELETE,                  /* name, stock id */
    "_Delete","<control>D",                       /* label, accelerator */
    "Delete a record",                          /* tooltip */
    G_CALLBACK (My_GUI::remove_item) },
  { "Quit", GTK_STOCK_QUIT,                    /* name, stock id */
    "_Quit", "<control>Q",                     /* label, accelerator */
    "Quit",                                    /* tooltip */
    G_CALLBACK (My_GUI::activate_action)},
  { "About", NULL,                             /* name, stock id */
    "_About", "<control>A",                    /* label, accelerator */
    "About",                                   /* tooltip */
    G_CALLBACK (My_GUI::about_cb) },
  { "Logo", "demo-gtk-logo",                   /* name, stock id */
     NULL, NULL,                               /* label, accelerator */
    "GTK+",                                    /* tooltip */
    G_CALLBACK (My_GUI::activate_action) },
};
static guint n_entries = G_N_ELEMENTS (entries);


static GtkToggleActionEntry toggle_entries[] = {
  { "Bold", GTK_STOCK_BOLD,                    /* name, stock id */
     "_Bold", "<control>B",                    /* label, accelerator */
    "Bold",                                    /* tooltip */
    G_CALLBACK (My_GUI::activate_action),
    TRUE },                                    /* is_active */
};
static guint n_toggle_entries = G_N_ELEMENTS (toggle_entries);

enum {
  COLOR_RED,
  COLOR_GREEN,
  COLOR_BLUE
};

static GtkRadioActionEntry color_entries[] = {
  { "Red", NULL,                               /* name, stock id */
    "_Red", "<control>R",                      /* label, accelerator */
    "Blood", COLOR_RED },                      /* tooltip, value */
  { "Green", NULL,                             /* name, stock id */
    "_Green", "<control>G",                    /* label, accelerator */
    "Grass", COLOR_GREEN },                    /* tooltip, value */
  { "Blue", NULL,                              /* name, stock id */
    "_Blue", "<control>B",                     /* label, accelerator */
    "Sky", COLOR_BLUE },                       /* tooltip, value */
};
static guint n_color_entries = G_N_ELEMENTS (color_entries);

enum {
  SHAPE_SQUARE,
  SHAPE_RECTANGLE,
  SHAPE_OVAL
};

static GtkRadioActionEntry shape_entries[] = {
  { "Square", NULL,                            /* name, stock id */
    "_Square", "<control>S",                   /* label, accelerator */
    "Square",  SHAPE_SQUARE },                 /* tooltip, value */
  { "Rectangle", NULL,                         /* name, stock id */
    "_Rectangle", "<control>R",                /* label, accelerator */
    "Rectangle", SHAPE_RECTANGLE },            /* tooltip, value */
  { "Oval", NULL,                              /* name, stock id */
    "_Oval", "<control>O",                     /* label, accelerator */
    "Egg", SHAPE_OVAL },                       /* tooltip, value */
};
static guint n_shape_entries = G_N_ELEMENTS (shape_entries);

static const gchar *ui_info =
"<ui>"
"  <menubar name='MenuBar'>"
"    <menu action='EditMenu'>"
"      <menuitem action='New'/>"
"      <menuitem action='Open'/>"
"      <menuitem action='Save'/>"
"      <menuitem action='Delete'/>"
"      <separator/>"
"      <menuitem action='Quit'/>"
"    </menu>"
"    <menu action='PreferencesMenu'>"
"      <menu action='ColorMenu'>"
"	<menuitem action='Red'/>"
"	<menuitem action='Green'/>"
"	<menuitem action='Blue'/>"
"      </menu>"
"      <menu action='ShapeMenu'>"
"        <menuitem action='Square'/>"
"        <menuitem action='Rectangle'/>"
"        <menuitem action='Oval'/>"
"      </menu>"
"      <menuitem action='Bold'/>"
"    </menu>"
"    <menu action='HelpMenu'>"
"      <menuitem action='About'/>"
"    </menu>"
"  </menubar>"
"  <toolbar  name='ToolBar'>"
"    <toolitem action='Open'/>"
"    <toolitem action='Quit'/>"
"    <separator action='Sep1'/>"
"    <toolitem action='Logo'/>"
"  </toolbar>"
"</ui>";

#endif /* MYGUI_H_ */
